package user;

import book.BookList;
import operation.*;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-11-21
 * Time: 20:01
 */
public class NormalUser extends User {

    //构造方法:
    public NormalUser(String name) {
        super(name);
        //父类无法确定iOperations的大小(存在两个用户)，所以在子类中定义
        //涉及知识点:数组初始化:
        this.iOperations = new IOperation[]{
                new ExitOperation(),
                new FindOperation(),            //父类实例引用子类对象
                new BorrowOperation(),          //这里是数组，每个元素之间都用逗号隔开（元素内容为实例化对象）
                new ReturnOperation()
        };
    }
    public int menu() {
        System.out.println("*****用户菜单*****");
        System.out.println("1.查找图书");
        System.out.println("2.借阅图书");
        System.out.println("3.归还图书");
        System.out.println("0.退出系统");
        System.out.println("****************");
        System.out.println("请输入你的操作：->");
        Scanner scanner = new Scanner(System.in);
        int choice = scanner.nextInt();
        return choice;
    }

    @Override
    public void doOperation(int choice, BookList bookList) {
        this.iOperations[choice].work(bookList);
    }
}
